package lokal.lueder;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JTextArea;
import java.awt.ComponentOrientation;
import javax.swing.JTextPane;
import javax.swing.JEditorPane;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class LChatClient2 extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel jPanelStart;  //  @jve:decl-index=0:visual-constraint="381,56"
	private JTextField jTextFieldName;
	private JLabel jLabelTitle;
	private JButton jButtonAnmelden;
	private JLabel jLabelPw;
	private JLabel jLabelName;
	private JPasswordField jPasswordField;
	private JTextField jTextFieldIn = null;
	private JTextArea jTextAreaOut = null;
	private JScrollPane jScrollPaneOut = null;
	/**
	 * This method initializes jTextFieldIn	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldIn() {
		if (jTextFieldIn == null) {
			jTextFieldIn = new JTextField();
			jTextFieldIn.setBounds(new Rectangle(17, 146, 211, 20));
		}
		return jTextFieldIn;
	}

	/**
	 * This method initializes jTextAreaOut	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JTextArea getJTextAreaOut() {
		if (jTextAreaOut == null) {
			jTextAreaOut = new JTextArea();
			jTextAreaOut.setBounds(new Rectangle(17, 34, 208, 105));
			jTextAreaOut.setAutoscrolls(true);
			
		}
		return jTextAreaOut;
	}
	
	private JScrollPane getJScrollPaneOut(JTextArea jta) {
		if (jScrollPaneOut == null) {
			jScrollPaneOut = new JScrollPane(jta);
			jScrollPaneOut.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
			
		}
		return jScrollPaneOut;
	}
	
	

	/**
	 * Auto-generated main method to display this JFrame
	 */
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				LChatClient2 inst = new LChatClient2();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}

	public LChatClient2() {
		super();
		initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jPanelStart = new JPanel();
				getContentPane().add(jPanelStart, BorderLayout.CENTER);
				jPanelStart.setLayout(null);
				setTitle("LChat");
				{
					jTextFieldName = new JTextField();
					jPanelStart.add(jTextFieldName);
					jTextFieldName.setBounds(147, 73, 116, 23);
				}
				{
					jPasswordField = new JPasswordField();
					jPanelStart.add(jPasswordField);
					jPasswordField.setBounds(147, 108, 116, 23);
				}
				{
					jLabelName = new JLabel();
					jPanelStart.add(jLabelName);
					jLabelName.setText("Name");
					jLabelName.setBounds(72, 76, 65, 16);
				}
				{
					jLabelPw = new JLabel();
					jPanelStart.add(jLabelPw);
					jLabelPw.setText("Passwort");
					jLabelPw.setBounds(72, 111, 80, 16);
				}
				{
					jButtonAnmelden = new JButton();
					jPanelStart.add(jButtonAnmelden);
					jButtonAnmelden.setText("Anmelden");
					jButtonAnmelden.setBounds(147, 143, 116, 23);
					jButtonAnmelden.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							initChat();
						}
					});
				}
				{
					jLabelTitle = new JLabel();
					jPanelStart.add(jLabelTitle);
					jLabelTitle.setText("Anmelden");
					jLabelTitle.setBounds(12, 12, 135, 16);
					jLabelTitle.setFont(new java.awt.Font("Segoe UI", 1, 18));
				}

			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
			// add your error handling code here
			e.printStackTrace();
		}
	}

	private void initChat() {
		System.out.println("Test");
		getContentPane().remove(jPanelStart);
		getContentPane().update(getContentPane().getGraphics());

		jPanelStart = new JPanel();
		getContentPane().add(jPanelStart, BorderLayout.CENTER);
		jPanelStart.setLayout(null);
		jPanelStart.setSize(new Dimension(247, 174));
		jPanelStart.add(jLabelTitle, null);
		jPanelStart.add(getJTextFieldIn(), null);
		jPanelStart.add(getJScrollPaneOut(getJTextAreaOut()), BorderLayout.CENTER);
		
		getContentPane().add(jPanelStart);
		getContentPane().update(getContentPane().getGraphics());
		getContentPane().setVisible(false);
		getContentPane().setVisible(true);
		{
			jPanelStart.add(jLabelTitle);
			jLabelTitle.setText("Chat");
		}
		setSize(400, 300);
	}

}
